/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	FBXUtility.h
*
*	Description -	Wrapper class for simplifying basic FBX methods.
*
*	Comments	-	TODO: Make this part of Pulse-Tec Lib once this becomes stable.
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	09/11/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_FBX_UTILITY_H_
#define _PSX_FBX_UTILITY_H_

#include "../Pulse-Tec/Include/Pulse.h"
#include "GeometryFileWriter.h"

// FBX
#include <fbxsdk.h>

namespace Pulse
{
	class FBXUtility
	{
	public:

		FBXUtility( void );

		~FBXUtility( void );

		EErrorCode::Type LoadScene( const CHAR *pFilename );

		const FbxNode * GetRootNode( void );

		const Char * GetRootNodeName( void );

		// NOTE: This method simply finds the first mesh it finds, exports it, then returns.
		EErrorCode::Type ExportGeometry( void ) { return FindMeshToProcess( m_pScene->GetRootNode() ); }

		BOOL TriangulateScene( void ) { return TriangulateRecursive( m_pScene->GetRootNode() ); }

	private:

		EErrorCode::Type Initialize( void );

		void Cleanup( void );

		BOOL TriangulateRecursive( FbxNode *pNode );

		EErrorCode::Type FindMeshToProcess( FbxNode *pNode );

		EErrorCode::Type ProcessMesh( FbxNode *pMeshNode );

		FbxManager *m_pSDKManager;
		FbxScene   *m_pScene;

		GeometryFileWriter m_fileWriter;

	};
}

#endif /* _PSX_FBX_UTILITY_H_ */